/**
 * 
 */
package com.ptma.model;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * @author YahyaArshad
 * 
 */
@Entity
@Table(name = "APPLICATION")
public class Application implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue
	@Column(name = "application_id")
	private Long id;

	@Column(name = "name")
	private String name;

	@Column(name = "name_space")
	private String nameSpace;

	@Column(name = "comment")
	private String comment;

	@Column(name = "update_time")
	private Timestamp updateTime;

	@Column(name = "creation_time")
	private Timestamp creationTime = new Timestamp(System.currentTimeMillis());

	@OneToMany
	@JoinColumn(name = "fk_application_id", referencedColumnName = "application_id")
	private Set<ApplicationVersion> versions;

	public Timestamp getCreationTime() {
		return creationTime;
	}

	public void setCreationTime(Timestamp creationTime) {
		this.creationTime = creationTime;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getNameSpace() {
		return nameSpace;
	}

	public void setNameSpace(String nameSpace) {
		this.nameSpace = nameSpace;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public Timestamp getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Timestamp updateTime) {
		this.updateTime = updateTime;
	}

	public Set<ApplicationVersion> getVersions() {
		return versions;
	}

	public void setVersions(Set<ApplicationVersion> versions) {
		this.versions = versions;
	}

	@Override
	public int hashCode() {

		return id.hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (null == obj || !(obj instanceof Application)) {
			return false;
		}

		return this.id == ((Application) obj).id;
	}

}
